/**
 * 首页
 * */


//首页统计
function indexTongji(){
    $.ajax({
        type: apis.indexTongji.method,
        url: apis.indexTongji.url,
        data: {},
        success: function (res) {
            console.log(res);
            if (res.code < 0) {
                return
            }
            fd = res.data;
            indexHtml();
        },
        error: function () {
            console.log('错误辣');
        }
    });
}
//首页字符串
function indexHtml(){
    var h = '', i;
    //数据看板-流水看板
    h = '';
    h += '<tr class="text-c">';
    h += '<td>今日订单数</td>';
    h += '<td>' + fd.today.orderNum + '</td>';
    h += '<td>总订单数</td>';
    h += '<td>' + fd.total.orderNum + '</td>';
    h += '</tr>';
    h += '<tr class="text-c">';
    h += '<td>今日销售额</td>';
    h += '<td>' + fd.today.saleNum + '</td>';
    h += '<td>总销售额</td>';
    h += '<td>' + fd.today.saleNum + '</td>';
    h += '</tr>';
    h += '<tr class="text-c">';
    h += '<td>今日浏览量</td>';
    h += '<td>' + fd.today.readNum + '</td>';
    h += '<td>总浏览量</td>';
    h += '<td>' + fd.total.readNum + '</td>';
    h += '</tr>';
    h += '<tr class="text-c">';
    h += '<td>今日充值金额</td>';
    h += '<td>' + fd.today.recharge + '</td>';
    h += '<td>总充值金额</td>';
    h += '<td>' + fd.total.recharge + '</td>';
    h += '</tr>';
    h += '<tr class="text-c">';
    h += '<td>今日新增会员数</td>';
    h += '<td>' + fd.today.userNum + '</td>';
    h += '<td>会员总数</td>';
    h += '<td>' + fd.total.userNum + '</td>';
    h += '</tr>';
    $('#kanban01').html(h);
    //数据看板-商品看板
    h = '';
    if (fd.goods.length == 0) {
        h += '<tr class="text-c">';
        h += '<td colspan="10">没有记录</td>';
        h += '</tr>';
    } else {
        for (i = 0; i < fd.goods.length; i ++) {
            h += '<tr class="text-c">';
            h += '<td>' + fd.goods[i].title + '</td>';
            h += '<td>' + fd.goods[i].readNum + '</td>';
            h += '<td>' + fd.goods[i].orderNum + '</td>';
            h += '</tr>';
        }
    }
    $('#kanban02').html(h);
    //数据看板-库存看板
    h = '';
    if (fd.stock.length == 0) {
        h += '<tr class="text-c">';
        h += '<td colspan="10">没有记录</td>';
        h += '</tr>';
    } else {
        for (i = 0; i < fd.stock.length; i ++) {
            h += '<tr class="text-c">';
            h += '<td>' + fd.stock[i].title + '</td>';
            h += '<td>' + fd.stock[i].skuName + '</td>';
            h += '<td>' + fd.stock[i].skuNum + '</td>';
            h += '</tr>';
        }
    }
    $('#kanban03').html(h);
    //数据看板-待办事项
    h = '';
    h += '<tr class="text-c">';
    h += '<td>' + fd.daiban.noPayNum + '</td>';
    h += '<td>' + fd.daiban.noSendNum + '</td>';
    h += '<td>' + fd.daiban.refundNum + '</td>';
    h += '<td>' + fd.daiban.shelfNum + '</td>';
    h += '<td>' + fd.daiban.qdAuthNum + '</td>';
    h += '</tr>';
    $('#kanban04').html(h);
    //数据看板-待办事项-零售库存预警
    h = '';
    if (fd.yujing.length == 0) {
        h += '<tr class="text-c">';
        h += '<td colspan="10">没有记录</td>';
        h += '</tr>';
    } else {
        for (i = 0; i < fd.yujing.length; i ++) {
            h += '<tr class="text-c">';
            h += '<td>' + fd.yujing[i].gname + '</td>';
            h += '<td>' + fd.yujing[i].gno + '</td>';
            h += '<td>' + fd.yujing[i].skuName + '</td>';
            h += '</tr>';
        }
    }
    $('#kanban05').html(h);
}


//财务统计
function caiwuTongji(){
    var formData = {
        //riqi01: $('#riqi1').val(),
        //riqi02: $('#riqi2').val(),
        rq01: rq01, rq02: rq02,
    };
    $.ajax({
        type: apis.caiwuTongji.method,
        url: apis.caiwuTongji.url,
        data: formData,
        success: function (res) {
            console.log(res);
            if (res.code < 0) {
                return
            }
            fd = res.data;
            caiwuHtml();
        },
        error: function () {
            console.log('错误辣');
        }
    });
}
//财务字符串
function caiwuHtml(){
    var h = '', i;
    //零售财务报表-零售商城销售总额
    h = '';
    h += '<tr class="text-c">';
    h += '<td>' + fd.lingshou.sell + '</td>';
    h += '<td>' + fd.lingshou.order + '</td>';
    h += '<td>' + fd.lingshou.yue + '</td>';
    h += '<td>' + fd.lingshou.recharge + '</td>';
    h += '<td>' + fd.lingshou.card + '</td>';
    h += '<td>' + fd.lingshou.refund + '</td>';
    h += '<td>' + fd.lingshou.tixian + '</td>';
    h += '</tr>';
    $('#kanban01').html(h);
    //零售财务报表-零售商城收入总额
    h = '';
    h += '<tr class="text-c">';
    h += '<td>' + fd.lsin.sell + '</td>';
    h += '<td>' + fd.lsin.shop + '</td>';
    h += '<td>' + fd.lsin.recharge + '</td>';
    h += '<td>' + fd.lsin.card + '</td>';
    h += '</tr>';
    $('#kanban02').html(h);
    //零售财务报表-零售商城支出总额
    h = '';
    h += '<tr class="text-c">';
    h += '<td>' + fd.lsout.sell + '</td>';
    h += '<td>' + fd.lsout.tixian + '</td>';
    h += '<td>' + fd.lsout.refund + '</td>';
    h += '</tr>';
    $('#kanban03').html(h);
    //渠道财务报表
    h = '';
    h += '<tr class="text-c">';
    h += '<td>' + fd.qudao.sell + '</td>';
    h += '<td>' + fd.qudao.yue + '</td>';
    h += '<td>' + fd.qudao.recharge + '</td>';
    h += '<td>' + fd.qudao.refund + '</td>';
    h += '<td>' + fd.qudao.tixian + '</td>';
    h += '</tr>';
    $('#kanban04').html(h);
    //渠道财务报表-渠道商城收入总额
    h = '';
    h += '<tr class="text-c">';
    h += '<td>' + fd.qdIn.total + '</td>';
    h += '<td>' + fd.qdIn.shop + '</td>';
    h += '<td>' + fd.qdIn.recharge + '</td>';
    h += '</tr>';
    $('#kanban05').html(h);
    //渠道财务报表-渠道商城支出总额
    h = '';
    h += '<tr class="text-c">';
    h += '<td>' + fd.qdOut.total + '</td>';
    h += '<td>' + fd.qdOut.tixian + '</td>';
    h += '<td>' + fd.qdOut.refund + '</td>';
    h += '</tr>';
    $('#kanban06').html(h);
}